package timu1;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {
    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, InstantiationException {
        Class clazz=person.class;
        person person=new person("张三");
        Field name = clazz.getDeclaredField("name");
        name.setAccessible(true);
        name.set(person,"李华");
        Constructor constructor = clazz.getConstructor();
        Object o = constructor.newInstance();
        Method sayHello = clazz.getDeclaredMethod("sayHello");
        sayHello.invoke(person);
    }
}